package jmcnet.libcommun.communs.enum
{
	import flash.errors.IllegalOperationError;
	

	/**
	 * 
	 */
	[Bindable]
	public class EnumBase {
   	    
	    [Bindable]
		protected var _value:String;
	    
	    /**
	     * The EnumBase CTOR. This CTOR should be protected to allow instanciation only from sub-classes.
	     * But AS3 don't allow protected CTOR. So, be careful ...
	     */
	    public function EnumBase(value:String) {
	        this._value = value;
	    }
	    
	    /**
	     * @see java.lang.Object#toString()
	     */
	    public function toString():String { return _value; }
	
	    /**
	     * Gets the underlying value of this type safe enumeration.
	     *
	     * @return the underlying value.
	     */
	    public function get value():String { return this._value; }
	
	    /**
	     * @see java.lang.Comparable#compareTo(java.lang.Object)
	     */
	    public function compareTo(that:Object):int
	    {
	        return (this == that) ? 0 : this.value.localeCompare((that as EnumBase).value);
	    }
	    
	    /**
	     * @see java.lang.Object#equals(java.lang.Object)
	     */
	    public function equals(object:Object):Boolean {
	        return (this == object)
	            // || (object instanceof EnumEtatProjet && ((EnumEtatProjet)object).getValue().equals(
	            || (object is EnumBase && (object as EnumBase).value == 
	                this.value);
	    }
	    
	    /**
	     * An abstract 'selectedIndex' property (must be implemented in subclasses
	     */
	    public function get selectedIndex():int {
	    	throw UninitializedError("ERROR : function 'selectedIndex' must be implemented in EnumBase subclasses");
	    }
	}
}